﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FRS.FileProcessor
{
    public static class GeoFilePathGetter
    {
        /// <summary>
        /// 选择一个shp文件打开，返回用户指定的路径【如果取消则返回NULL】
        /// </summary>
        /// <returns>用户指定的路径</returns>
        public static string GetShpOpenPath()
        {
            string path = null;
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Title = "打开Shp点图层文件";
            openFileDialog.Filter = "Shape文件(*.shp)|*.shp";
            openFileDialog.ShowDialog();
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                path = openFileDialog.FileName;
            }
            return path;
        }
        /// <summary>
        /// 选择一个路径保存Tin文件【如果取消则返回NULL】
        /// </summary>
        /// <returns>用户选择的路径</returns>
        public static string GetTinSavePath()
        {
            string path = null;
            SaveFileDialog saveTIN = new SaveFileDialog();
            saveTIN.Title = "选择TIN文件保存路径";
            saveTIN.Filter = "TIN(*.tin)|*.tin|All files (*.*)|*.*";
            saveTIN.RestoreDirectory = true;

            if (saveTIN.ShowDialog() == DialogResult.OK)
            {
                path = saveTIN.FileName;

            }
            return path;
        }
        /// <summary>
        /// 选择一个Dem数据文件打开，返回用户指定的路径【如果取消则返回NULL】
        /// </summary>
        /// <returns>用户指定的路径</returns>
        public static string GetDemOpenPath()
        {
            string path = null;
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Title = "打开.tif文件";
            openFileDialog.Filter = ".tif文件(*.tif)|*.tif|PNG(*.png)|*.png";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                path = openFileDialog.FileName;
            }
            return path;
        }
        /// <summary>
        /// 选择一个Geodatabase文件打开，返回用户指定的路径【如果取消则返回NULL】
        /// </summary>
        /// <returns>用户指定的空间数据库文件路径</returns>
        public static string GetGeodatabaseOpenPath()
        {
            string path = null;
            FolderBrowserDialog dlg = new FolderBrowserDialog();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                path = dlg.SelectedPath;
            }
            return path;
        }
    }
}
